import Vue from "vue"
import Vuex from "vuex"
import getters from "./getters"
import mutations from "./mutations"
import state from "./state"

const fileModules = import.meta.globEager("./modules/*.js")
const modules = Object.keys(fileModules).reduce((modules, path) => {
  const moduleName = path.match(/(\w+).js$/)[1]
  modules[moduleName] = fileModules[path].default
  return modules
}, {})

console.log({ modules })

Vue.use(Vuex)

const store = new Vuex.Store({
  state,
  modules,
  getters,
  mutations,
})

export default store
